package com.ssy.lingxi.report.serviceimpl.tally;

import com.ssy.lingxi.report.api.enums.*;
import com.ssy.lingxi.report.api.vo.request.OperateNoticeVO;
import com.ssy.lingxi.report.dao.order.*;
import com.ssy.lingxi.report.entity.report.MemberTallyReportDO;
import com.ssy.lingxi.report.model.bo.MemberTallyReportBO;
import com.ssy.lingxi.report.model.bo.StatisticsCountBO;
import com.ssy.lingxi.report.model.bo.tally.*;
import com.ssy.lingxi.report.model.bo.tally.statistics.*;
import com.ssy.lingxi.report.model.vo.response.TallyReportItemVO;
import com.ssy.lingxi.report.model.vo.response.TradeTallyReportVO;
import com.ssy.lingxi.report.service.tally.ITradeTallyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 交易中心计数统计接口实现
 * @author 伍将
 * @date 2020/11/23
 * @version 2.0.0
 */
@Service
public class TradeTallyServiceImpl implements ITradeTallyService {

    private static final Logger logger = LoggerFactory.getLogger(TradeTallyServiceImpl.class);

    @Autowired
    private InquiryListDAO inquiryListDAO;

    @Autowired
    private ProductQuotationDAO productQuotationDAO;

    @Autowired
    private RequisitionFormDAO requisitionFormDAO;

    @Autowired
    private QuotationDAO quotationDAO;

    @Autowired
    private ProcurementOrderDAO procurementOrderDAO;

    /**
     * 转换交易中心
     * @param reportBO
     * @return
     */
    @Override
    public TradeTallyReportVO convertTradeTally(MemberTallyReportBO reportBO) {
        TradeTallyReportVO result = new TradeTallyReportVO();
        if (reportBO == null) {
            reportBO = new MemberTallyReportBO();
        }
        // 商品询价
        result.setCommodityInquiryList(convertTradeCommodityInquiryTally(reportBO.getTradeCommodityInquiry()));
        // 询价报价
        result.setInquiryQuotationList(convertTradeInquiryQuotationTally(reportBO.getTradeInquiryQuotation()));
        // 确认询价报价
        result.setConfirmInquiryQuotationList(convertTradeConfirmInquiryQuotationTally(reportBO.getTradeConfirmInquiryQuotation()));
        // 需求发布
        //result.setDemandPublishList(convertTradeDemandPublishTally(reportBO.getTradeDemandPublish()));
        // 需求报价
        //result.setDemandQuotationList(convertTradeDemandQuotationTally(reportBO.getTradeDemandQuotation()));
        // 确认需求报价
        //result.setConfirmDemandQuotationList(convertTradeConfirmDemandQuotationTally(reportBO.getTradeConfirmDemandQuotation()));
        // 销售订单
        //已转到订单中心 result.setSaleOrderList(convertTradeSaleOrderTally(reportBO.getTradeSaleOrder()));
        // 采购订单
        //已转到订单中心 result.setPurchaseOrderList(convertTradePurchaseOrderTally(reportBO.getTradePurchaseOrder()));

        return result;
    }

    /**
     * 设置交易中心
     * @param tallyReportO
     * @param noticeVO
     * @return
     */
    @Override
    public MemberTallyReportBO setTradeTally(MemberTallyReportBO tallyReportO, OperateNoticeVO noticeVO) {
        OperateDataSourceEnum sourceEnum = OperateDataSourceEnum.getEnum(noticeVO.getDataSource());
        switch (sourceEnum) {
            case TRADE_COMMODITY_INQUIRY: // 商品询价
                tallyReportO.setTradeCommodityInquiry(setTradeCommodityInquiryTally(tallyReportO.getTradeCommodityInquiry(), noticeVO));
                break;
            case TRADE_INQUIRY_QUOTATION: // 询价报价
                tallyReportO.setTradeInquiryQuotation(setTradeInquiryQuotationTally(tallyReportO.getTradeInquiryQuotation(), noticeVO));
                break;
            case TRADE_CONFIRM_INQUIRY_QUOTATION: // 确认询价报价
                tallyReportO.setTradeConfirmInquiryQuotation(setTradeConfirmInquiryQuotationTally(tallyReportO.getTradeConfirmInquiryQuotation(), noticeVO));
                break;
            case TRADE_DEMAND_PUBLISH: // 需求发布
                tallyReportO.setTradeDemandPublish(setTradeDemandPublishTally(tallyReportO.getTradeDemandPublish(), noticeVO));
                break;
            case TRADE_DEMAND_QUOTATION: // 需求报价
                tallyReportO.setTradeDemandQuotation(setTradeDemandQuotationTally(tallyReportO.getTradeDemandQuotation(), noticeVO));
                break;
            case TRADE_CONFIRM_DEMAND_QUOTATION: // 确认需求报价
                tallyReportO.setTradeConfirmDemandQuotation(setTradeConfirmDemandQuotationTally(tallyReportO.getTradeConfirmDemandQuotation(), noticeVO));
                break;
/*            case TRADE_SALE_ORDER: // 销售订单
                tallyReportO.setTradeSaleOrder(setTradeSaleOrderTally(tallyReportO.getTradeSaleOrder(), noticeVO));
                break;
            case TRADE_PURCHASE_ORDER: // 采购订单
                tallyReportO.setTradePurchaseOrder(setTradePurchaseOrderTally(tallyReportO.getTradePurchaseOrder(), noticeVO));
                break;*/
        }
        return tallyReportO;
    }

    /**
     * 转换商品询价
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradeCommodityInquiryTally(TradeCommodityInquiryTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradeCommodityInquiryTallyBO();
        }
        // 待提交审核
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(CommodityInquiryOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(CommodityInquiryOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(CommodityInquiryOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(CommodityInquiryOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(CommodityInquiryOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(CommodityInquiryOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待提交
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount());
        tallyReportItem.setName(CommodityInquiryOperateTypeEnum.TO_BE_COMMIT.getName());
        tallyReportItem.setLink(CommodityInquiryOperateTypeEnum.TO_BE_COMMIT.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 转换询价报价
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradeInquiryQuotationTally(TradeInquiryQuotationTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradeInquiryQuotationTallyBO();
        }
        // 待提交审核
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(InquiryQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(InquiryQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(InquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(InquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(InquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(InquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount());
        tallyReportItem.setName(InquiryQuotationOperateTypeEnum.TO_BE_COMMIT.getName());
        tallyReportItem.setLink(InquiryQuotationOperateTypeEnum.TO_BE_COMMIT.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 转换确认询价报价
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradeConfirmInquiryQuotationTally(TradeConfirmInquiryQuotationTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradeConfirmInquiryQuotationTallyBO();
        }

        // 待提交审核
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmCount());
        tallyReportItem.setName(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_CONFIRM.getName());
        tallyReportItem.setLink(ConfirmInquiryQuotationOperateTypeEnum.TO_BE_CONFIRM.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 转换需求发布
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradeDemandPublishTally(TradeDemandPublishTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradeDemandPublishTallyBO();
        }
        // 待提交审核
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(DemandPublishOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(DemandPublishOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(DemandPublishOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(DemandPublishOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(DemandPublishOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(DemandPublishOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount());
        tallyReportItem.setName(DemandPublishOperateTypeEnum.TO_BE_COMMIT.getName());
        tallyReportItem.setLink(DemandPublishOperateTypeEnum.TO_BE_COMMIT.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 转换需求报价
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradeDemandQuotationTally(TradeDemandQuotationTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradeDemandQuotationTallyBO();
        }
        // 待提交审核
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(DemandQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(DemandQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(DemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(DemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(DemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(DemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount());
        tallyReportItem.setName(DemandQuotationOperateTypeEnum.TO_BE_COMMIT.getName());
        tallyReportItem.setLink(DemandQuotationOperateTypeEnum.TO_BE_COMMIT.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 转换确认需求报价
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradeConfirmDemandQuotationTally(TradeConfirmDemandQuotationTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradeConfirmDemandQuotationTallyBO();
        }
        // 待提交审核
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(ConfirmDemandQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(ConfirmDemandQuotationOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(ConfirmDemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(ConfirmDemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(ConfirmDemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(ConfirmDemandQuotationOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmCount());
        tallyReportItem.setName(ConfirmDemandQuotationOperateTypeEnum.TO_BE_CONFIRM.getName());
        tallyReportItem.setLink(ConfirmDemandQuotationOperateTypeEnum.TO_BE_CONFIRM.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 转换销售订单
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradeSaleOrderTally(TradeSaleOrderTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradeSaleOrderTallyBO();
        }

        // 待提交审核数
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_CONFIRM.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_CONFIRM.getLink());
        resultList.add(tallyReportItem);
        // 待确认支付结果订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmPayResultCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_CONFIRM_PAY_RESULT.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_CONFIRM_PAY_RESULT.getLink());
        resultList.add(tallyReportItem);
        // 待新增销售发货单订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeAddDeliveryGoodsCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_ADD_DELIVERY_GOODS.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_ADD_DELIVERY_GOODS.getLink());
        resultList.add(tallyReportItem);
        // 待新增物流单订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeAddLogisticsCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_ADD_LOGISTICS.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_ADD_LOGISTICS.getLink());
        resultList.add(tallyReportItem);
        // 待确认发货订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmDeliveryGoodsCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_CONFIRM_DELIVERY_GOODS.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_CONFIRM_DELIVERY_GOODS.getLink());
        resultList.add(tallyReportItem);
        // 待确认回单订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmReceiptCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_CONFIRM_RECEIPT.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_CONFIRM_RECEIPT.getLink());
        resultList.add(tallyReportItem);
        // 待归档订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeArchiveCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_ARCHIVE.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_ARCHIVE.getLink());
        resultList.add(tallyReportItem);
        // 待评价订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeEvaluateCount());
        tallyReportItem.setName(SaleOrderOperateTypeEnum.TO_BE_EVALUATE.getName());
        tallyReportItem.setLink(SaleOrderOperateTypeEnum.TO_BE_EVALUATE.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 转换采购订单
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTradePurchaseOrderTally(TradePurchaseOrderTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new TradePurchaseOrderTallyBO();
        }
        // 待提交审核数
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_VALIFY_COMMIT.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_VALIFY_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待提交
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_COMMIT.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_COMMIT.getLink());
        resultList.add(tallyReportItem);
        // 待确认电子合同订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmContractCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_CONFIRM_CONTRACT.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_CONFIRM_CONTRACT.getLink());
        resultList.add(tallyReportItem);
        // 待支付订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBePayCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_PAY.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_PAY.getLink());
        resultList.add(tallyReportItem);
        // 待新增采购入库单订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeAddStorageCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_ADD_STORAGE.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_ADD_STORAGE.getLink());
        resultList.add(tallyReportItem);
        // 待确认收货订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmReceiveGoodsCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_CONFIRM_RECEIVE_GOODS.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_CONFIRM_RECEIVE_GOODS.getLink());
        resultList.add(tallyReportItem);
        // 待归档订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeArchiveCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_ARCHIVE.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_ARCHIVE.getLink());
        resultList.add(tallyReportItem);
        // 待评价订单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeEvaluateCount());
        tallyReportItem.setName(PurchaseOrderOperateTypeEnum.TO_BE_EVALUATE.getName());
        tallyReportItem.setLink(PurchaseOrderOperateTypeEnum.TO_BE_EVALUATE.getLink());
        resultList.add(tallyReportItem);

        resultList.forEach(o -> o.setCount(o.getCount() > 0 ? o.getCount() : 0));

        return resultList;
    }

    /**
     * 设置商品询价
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradeCommodityInquiryTallyBO setTradeCommodityInquiryTally(TradeCommodityInquiryTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradeCommodityInquiryTallyBO();
        }
        // 更新数据
        CommodityInquiryOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = CommodityInquiryOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = CommodityInquiryOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 设置询价报价
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradeInquiryQuotationTallyBO setTradeInquiryQuotationTally(TradeInquiryQuotationTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradeInquiryQuotationTallyBO();
        }
        // 更新数据
        InquiryQuotationOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = InquiryQuotationOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = InquiryQuotationOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 设置确认询价报价
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradeConfirmInquiryQuotationTallyBO setTradeConfirmInquiryQuotationTally(TradeConfirmInquiryQuotationTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradeConfirmInquiryQuotationTallyBO();
        }
        // 更新数据
        ConfirmInquiryQuotationOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = ConfirmInquiryQuotationOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = ConfirmInquiryQuotationOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 设置需求发布
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradeDemandPublishTallyBO setTradeDemandPublishTally(TradeDemandPublishTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradeDemandPublishTallyBO();
        }
// 更新数据
        DemandPublishOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = DemandPublishOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                    case TO_BE_VALIFY:
                        tallyBO.setToBeValifyCount(tallyBO.getToBeValifyCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = DemandPublishOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY:
                        tallyBO.setToBeValifyCount(tallyBO.getToBeValifyCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 设置需求报价
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradeDemandQuotationTallyBO setTradeDemandQuotationTally(TradeDemandQuotationTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradeDemandQuotationTallyBO();
        }
// 更新数据
        DemandQuotationOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = DemandQuotationOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = DemandQuotationOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 设置确认需求报价
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradeConfirmDemandQuotationTallyBO setTradeConfirmDemandQuotationTally(TradeConfirmDemandQuotationTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradeConfirmDemandQuotationTallyBO();
        }
        // 更新数据
        ConfirmDemandQuotationOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = ConfirmDemandQuotationOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = ConfirmDemandQuotationOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 设置销售订单
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradeSaleOrderTallyBO setTradeSaleOrderTally(TradeSaleOrderTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradeSaleOrderTallyBO();
        }
        // 更新数据
        SaleOrderOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = SaleOrderOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_PAY_RESULT:
                        tallyBO.setToBeConfirmPayResultCount(tallyBO.getToBeConfirmPayResultCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_ADD_DELIVERY_GOODS:
                        tallyBO.setToBeAddDeliveryGoodsCount(tallyBO.getToBeAddDeliveryGoodsCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_EVALUATE:
                        tallyBO.setToBeEvaluateCount(tallyBO.getToBeEvaluateCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_ARCHIVE:
                        tallyBO.setToBeArchiveCount(tallyBO.getToBeArchiveCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_RECEIPT:
                        tallyBO.setToBeConfirmReceiptCount(tallyBO.getToBeConfirmReceiptCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_DELIVERY_GOODS:
                        tallyBO.setToBeConfirmDeliveryGoodsCount(tallyBO.getToBeConfirmDeliveryGoodsCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_ADD_LOGISTICS:
                        tallyBO.setToBeAddLogisticsCount(tallyBO.getToBeAddLogisticsCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = SaleOrderOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_PAY_RESULT:
                        tallyBO.setToBeConfirmPayResultCount(tallyBO.getToBeConfirmPayResultCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_ADD_DELIVERY_GOODS:
                        tallyBO.setToBeAddDeliveryGoodsCount(tallyBO.getToBeAddDeliveryGoodsCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_EVALUATE:
                        tallyBO.setToBeEvaluateCount(tallyBO.getToBeEvaluateCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_ARCHIVE:
                        tallyBO.setToBeArchiveCount(tallyBO.getToBeArchiveCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_RECEIPT:
                        tallyBO.setToBeConfirmReceiptCount(tallyBO.getToBeConfirmReceiptCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_DELIVERY_GOODS:
                        tallyBO.setToBeConfirmDeliveryGoodsCount(tallyBO.getToBeConfirmDeliveryGoodsCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_ADD_LOGISTICS:
                        tallyBO.setToBeAddLogisticsCount(tallyBO.getToBeAddLogisticsCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 设置采购订单
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private TradePurchaseOrderTallyBO setTradePurchaseOrderTally(TradePurchaseOrderTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new TradePurchaseOrderTallyBO();
        }
        // 更新数据
        PurchaseOrderOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseOrderOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_CONTRACT:
                        tallyBO.setToBeConfirmContractCount(tallyBO.getToBeConfirmContractCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_PAY:
                        tallyBO.setToBePayCount(tallyBO.getToBePayCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_ADD_STORAGE:
                        tallyBO.setToBeAddStorageCount(tallyBO.getToBeAddStorageCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_RECEIVE_GOODS:
                        tallyBO.setToBeConfirmReceiveGoodsCount(tallyBO.getToBeConfirmReceiveGoodsCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_EVALUATE:
                        tallyBO.setToBeEvaluateCount(tallyBO.getToBeEvaluateCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_ARCHIVE:
                        tallyBO.setToBeArchiveCount(tallyBO.getToBeArchiveCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseOrderOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_COMMIT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_CONTRACT:
                        tallyBO.setToBeConfirmContractCount(tallyBO.getToBeConfirmContractCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_PAY:
                        tallyBO.setToBePayCount(tallyBO.getToBePayCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_ADD_STORAGE:
                        tallyBO.setToBeAddStorageCount(tallyBO.getToBeAddStorageCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_RECEIVE_GOODS:
                        tallyBO.setToBeConfirmReceiveGoodsCount(tallyBO.getToBeConfirmReceiveGoodsCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_EVALUATE:
                        tallyBO.setToBeEvaluateCount(tallyBO.getToBeEvaluateCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_ARCHIVE:
                        tallyBO.setToBeArchiveCount(tallyBO.getToBeArchiveCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }

        return tallyBO;
    }

    /**
     * 统计计数
     * @author 伍将
     * @date 2020/11/26
     * @param reportList:
     * @return:
     **/
    @Override
    public List<MemberTallyReportDO> statisticsTally(List<MemberTallyReportDO> reportList) {
        // 商品询价
        reportList = statisticsCommodityInquiryTally(reportList);

        // 询价报价
        reportList = statisticsInquiryQuotationTally(reportList);

        // 确认询价报价
        reportList = statisticsConfirmInquiryQuotationTally(reportList);

/*交易中心已无此模块        // 需求发布
        reportList = statisticsDemandPublishTally(reportList);

        // 需求报价
        reportList = statisticsDemandQuotationTally(reportList);

        // 确认需求报价
        reportList = statisticsConfirmDemandQuotationTally(reportList);*/

        // 销售订单
        reportList = statisticsSaleOrderTally(reportList);

        // 采购订单
        reportList = statisticsPurchaseOrderTally(reportList);

        return reportList;
    }

    /**
     * 采购订单统计
     * @author 伍将
     * @date 2020/12/2
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsPurchaseOrderTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<PurchaseOrderStatisticsTallyVO> tallyVOList = procurementOrderDAO.getPurchaseOrderStatistics();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());
        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "采购订单");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradePurchaseOrderTallyBO tallyBO = new TradePurchaseOrderTallyBO();
            PurchaseOrderStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (tallyVO != null) {
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                tallyBO.setToBeCommitCount(tallyVO.getToBeCommitCount());
                tallyBO.setToBeConfirmContractCount(tallyVO.getToBeConfirmContractCount());
                tallyBO.setToBePayCount(tallyVO.getToBePayCount());
                tallyBO.setToBeAddStorageCount(tallyVO.getToBeAddStorageCount());
                tallyBO.setToBeConfirmReceiveGoodsCount(tallyVO.getToBeConfirmReceiveGoodsCount());
                tallyBO.setToBeArchiveCount(tallyVO.getToBeArchiveCount());
                tallyBO.setToBeEvaluateCount(tallyVO.getToBeEvaluateCount());
            }
            p.getTallyReport().setTradePurchaseOrder(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 销售订单统计
     * @author 伍将
     * @date 2020/12/2
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsSaleOrderTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<SaleOrderStatisticsTallyVO> tallyVOList = procurementOrderDAO.getSaleOrderStatistics();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());
        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "销售订单");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradeSaleOrderTallyBO tallyBO = new TradeSaleOrderTallyBO();
            SaleOrderStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (tallyVO != null) {
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                tallyBO.setToBeConfirmCount(tallyVO.getToBeConfirmCount());
                tallyBO.setToBeConfirmPayResultCount(tallyVO.getToBeConfirmPayResultCount());
                tallyBO.setToBeAddDeliveryGoodsCount(tallyVO.getToBeAddDeliveryGoodsCount());
                tallyBO.setToBeAddLogisticsCount(tallyVO.getToBeAddLogisticsCount());
                tallyBO.setToBeConfirmDeliveryGoodsCount(tallyVO.getToBeConfirmDeliveryGoodsCount());
                tallyBO.setToBeConfirmReceiptCount(tallyVO.getToBeConfirmReceiptCount());
                tallyBO.setToBeArchiveCount(tallyVO.getToBeArchiveCount());
                tallyBO.setToBeEvaluateCount(tallyVO.getToBeEvaluateCount());
            }
            p.getTallyReport().setTradeSaleOrder(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 确认需求报价统计
     * @author 伍将
     * @date 2020/12/1
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsConfirmDemandQuotationTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<ConfirmDemandQuotationStatisticsTallyVO> tallyVOList = quotationDAO.getConfirmStatisticsCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());
        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "确认需求报价");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradeConfirmDemandQuotationTallyBO tallyBO = new TradeConfirmDemandQuotationTallyBO();
            ConfirmDemandQuotationStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待提交审核数
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待确认
                tallyBO.setToBeConfirmCount(tallyVO.getToBeConfirmCount());
            }

            p.getTallyReport().setTradeConfirmDemandQuotation(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 需求报价统计
     * @author 伍将
     * @date 2020/12/1
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsDemandQuotationTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<DemandQuotationStatisticsTallyVO> tallyVOList = quotationDAO.getStatisticsCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());
        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "需求报价");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradeDemandQuotationTallyBO tallyBO = new TradeDemandQuotationTallyBO();
            DemandQuotationStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待提交审核数
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待提交
                tallyBO.setToBeCommitCount(tallyVO.getToBeCommitCount());
            }

            p.getTallyReport().setTradeDemandQuotation(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 需求发布统计
     * @author 伍将
     * @date 2020/12/1
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsDemandPublishTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<DemandPublishStatisticsTallyVO> tallyVOList = requisitionFormDAO.getStatisticsCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());
        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "需求发布");
        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradeDemandPublishTallyBO tallyBO = new TradeDemandPublishTallyBO();
            DemandPublishStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待提交审核数
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待提交
                tallyBO.setToBeCommitCount(tallyVO.getToBeCommitCount());
            }

            p.getTallyReport().setTradeDemandPublish(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 确认询价报价统计
     * @author 伍将
     * @date 2020/12/1
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsConfirmInquiryQuotationTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<ConfirmInquiryQuotationStatisticsTallyVO> tallyVOList = productQuotationDAO.getConfirmStatisticsCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());
        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "确认询价报价");
        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradeConfirmInquiryQuotationTallyBO tallyBO = new TradeConfirmInquiryQuotationTallyBO();
            ConfirmInquiryQuotationStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待提交审核数
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待确认
                tallyBO.setToBeConfirmCount(tallyVO.getToBeConfirmCount());
            }
            p.getTallyReport().setTradeConfirmInquiryQuotation(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 询价报价统计
     * @author 伍将
     * @date 2020/12/1
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsInquiryQuotationTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<InquiryQuotationStatisticsTallyVO> tallyVOList = productQuotationDAO.getStatisticsCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());
        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "询价报价");
        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradeInquiryQuotationTallyBO tallyBO = new TradeInquiryQuotationTallyBO();
            InquiryQuotationStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待提交
                tallyBO.setToBeCommitCount(tallyVO.getToBeCommitCount());
            }
            p.getTallyReport().setTradeInquiryQuotation(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 商品询价统计
     * @author 伍将
     * @date 2020/12/1
     * @param reportList:
     * @return:
     **/
    private List<MemberTallyReportDO> statisticsCommodityInquiryTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<CommodityInquiryStatisticsTallyVO> tallyVOList = inquiryListDAO.getStatisticsCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "商品询价");
        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            TradeCommodityInquiryTallyBO tallyBO = new TradeCommodityInquiryTallyBO();
            CommodityInquiryStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (tallyVO != null) {
                // 待提交审核数
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待提交
                tallyBO.setToBeCommitCount(tallyVO.getToBeCommitCount());
            }
            p.getTallyReport().setTradeCommodityInquiry(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 补全数据
     * @param reportList
     * @param statisticsList
     * @param name
     * @return
     */
    private List<MemberTallyReportDO> replenishData(List<MemberTallyReportDO> reportList, List<StatisticsCountBO> statisticsList, String name) {
        if (statisticsList == null) {
            logger.info("没有符合条件的{}计数统计数据", name);
            statisticsList = new ArrayList<>();
        }

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = reportList;
        statisticsList.stream().distinct().forEach(p -> {
            MemberTallyReportDO reportDO = finalReportList.stream()
                    .filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId()))
                    .findFirst().orElse(null);
            if (reportDO == null) {
                reportDO = new MemberTallyReportDO();
                reportDO.setMemberId(p.getMemberId());
                reportDO.setRoleId(p.getRoleId());
                finalReportList.add(reportDO);
            }
        });

        return finalReportList;
    }
}
